package com.ithuang.demo.controller;

import com.ithuang.demo.service.FileService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import javax.annotation.Resource;
import java.io.File;
import java.io.IOException;

@RestController
@RequestMapping("/file")
public class FileController {

    @Resource
    private FileService fileService;

    @GetMapping("/upload")
    public String uploadFile(@RequestParam("file") MultipartFile file) throws Exception {
        fileService.FileAnalysis(file);
        return "ok";
    }

    @GetMapping("/upload2")
    public String uploadFile2(@RequestParam("file") MultipartFile file) throws Exception {
        fileService.FileAnalysis2(file.getInputStream());
        return "ok";
    }
}
